//和为s的两个数字之和
public class Solution {
    public int[] SumEqualsS(int[] nums, int target){
        if(nums == null || nums[0] > target){
            return null;
        }
        int[] ret = new int[2];
        int left = 0;
        int right = nums.length - 1;
        while(left < right && nums[right] >= target){
            right--;
        }
        //此时right为小于target的数字
        while(left < right){
            if(nums[left] + nums[right] > target){
                right--;
            }else if(nums[left] + nums[right] < target){
                left++;
            }else{
                ret[0] = nums[left];
                ret[1] = nums[right];
                break;
            }
        }
        //判断找到没有
        if(left < right){
            return ret;
        }else{
            return null;
        }
    }
}
